home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / interapplication comm / folder watching / fw receiver / menus.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-06-23  |  2.1 KB  |  132 lines

  1. /*
  2.     File:        Menus.c
  3.  
  4.     Contains:    Handles the application's menus
  5.  
  6.     Written by: Chris White    
  7.  
  8.     Copyright:    Copyright © 1995-1999 by Apple Computer, Inc., All Rights Reserved.
  9.  
  10.                 You may incorporate this Apple sample source code into your program(s) without
  11.                 restriction. This Apple sample source code has been provided "AS IS" and the
  12.                 responsibility for its operation is yours. You are not permitted to redistribute
  13.                 this Apple sample source code as "Apple sample source code" after having made
  14.                 changes. If you're going to re-distribute the source, we require that you make
  15.                 it clear in the source that the code was descended from Apple sample source
  16.                 code, but that you've made changes.
  17.  
  18.     Change History (most recent first):
  19.                 7/21/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  20.                 
  21.  
  22. */
  23.  
  24.  
  25. #pragma segment Core
  26.  
  27.  
  28. #ifndef __MENUS__
  29.     #include <Menus.h>
  30. #endif
  31.  
  32. #ifndef __WINDOWS__
  33.     #include <Windows.h>
  34. #endif
  35.  
  36. #ifndef __DIALOGS__
  37.     #include <Dialogs.h>
  38. #endif
  39.  
  40. #ifndef __TEXTUTILS__
  41.     #include <TextUtils.h>
  42. #endif
  43.  
  44. #ifndef __DESK__
  45.     #include <Desk.h>
  46. #endif
  47.  
  48.  
  49.  
  50.  
  51.  
  52. // Application includes
  53.  
  54. #ifndef __BAREBONES__
  55.     #include "BareBones.h"
  56. #endif
  57.  
  58. #ifndef __PROTOTYPES__
  59.     #include "Prototypes.h"
  60. #endif
  61.  
  62.  
  63.  
  64.  
  65. static void DoAppleCmds ( SInt16 theItem );
  66. static void DoFileCmds ( SInt16 theItem );
  67.  
  68.  
  69.  
  70.  
  71.  
  72. void MenuDispatch ( SInt32 menuResult )
  73. {
  74.     SInt16     theMenu = (menuResult >> 16);                    // menu selected
  75.     SInt16     theItem = (menuResult & 0x0000FFFF);               // item selected
  76.     
  77.     switch (theMenu)
  78.     {
  79.         case kAppleMenu: 
  80.             DoAppleCmds ( theItem );
  81.         break;
  82.         
  83.         case kFileMenu: 
  84.             DoFileCmds ( theItem );
  85.         break;
  86.         
  87.     }
  88.     
  89.     HiliteMenu ( 0 );               // un-hilite selected menu
  90.     
  91.     return;
  92.     
  93. } // MenuDispatch
  94.  
  95.  
  96.  
  97. static void DoAppleCmds ( SInt16 theItem )
  98. {
  99.     Str255    name;            // string for DA name
  100.     
  101.     
  102.     switch ( theItem )
  103.     {
  104.         case cAbout:
  105.             Alert ( kAboutDialog, nil );
  106.         break;
  107.         
  108.         default:
  109.             GetMenuItemText ( GetMenuHandle ( kAppleMenu ), theItem, (StringPtr) &name );
  110.             OpenDeskAcc ( (StringPtr) &name );
  111.         break;
  112.     }
  113. }
  114.  
  115.  
  116.  
  117. static void DoFileCmds ( SInt16 theItem )
  118. {    
  119.     switch ( theItem )
  120.     {
  121.         case cQuit:
  122.             gQuit = true;
  123.         break;
  124.     }
  125.     
  126.     return;
  127.     
  128. } // DoFileCmds
  129.  
  130.  
  131.  
  132.